import 'package:hrf_app/common/index.dart';
import 'package:hrf_app/common/services/user.dart';
import 'package:hrf_app/common/widgets/navigation.dart';
import 'package:hrf_app/pages/main_tab/main_menu_tab/controller.dart';
import 'package:hrf_app/pages/main_tab/main_menu_tab/view.dart';
import 'package:hrf_app/pages/main_tab/main_my_tab/view.dart';
import 'package:flutter/material.dart';

class ButtonTabbarDataHandler {
  List<NavigationItemModel> initializeMenuList() {
    List<NavigationItemModel> menuList = [];
    List<NavigationItemModel> menuListResult = [];
    getBugMenuList(menuList);
    List? roleList = UserService.to.profile.perms;
    if (roleList == null) {
      return [];
    }
    for (var vo in menuList) {
      if (roleList.contains(vo.hasPerm)) {
        menuListResult.add(vo);
      }
    }

    return menuListResult;
  }

  //bug-路由
  getBugMenuList(List<NavigationItemModel> menuList) {
    NavigationItemModel zx = NavigationItemModel(
      label: "菜单",
      icon: AssetsSvgs.menuSvg,
      hasPerm: "sys:menu",
      widget: const MainMenuTabPage(),
    );
    menuList.add(zx);
    NavigationItemModel my = NavigationItemModel(
      label: "我的",
      icon: AssetsSvgs.mySvg,
      hasPerm: "sys:my",
      widget: const MainMyTabPage(),
    );
    menuList.add(my);
  }
}
